home *** CD-ROM | disk | FTP | other *** search
- Path: orchard.la.locus.com!news
- From: rhyde <rhyde@cs.ucr.edu>
- Newsgroups: comp.lang.c++,comp.programming
- Subject: Re: Young programmers read me.
- Date: 18 Apr 1996 21:13:08 GMT
- Organization: uc riverside
- Message-ID: <4l6b94$lr9@orchard.la.locus.com>
- References: <4icpp9$7hr@barad-dur.nas.com> <4keejc$lpi@tpd.dsccc.com> <Pine.OSF.3.91.960411093444.20958D-100000@bud.cc.swin.edu.au> <4kmfqn$e0f@airdmhor.gen.nz> <4kubt3$2jk@plains.nodak.edu> <4l0c8p$rvp@fountain.mindlink.net> <4l1dn6$j3@belle.bork.com>
- NNTP-Posting-Host: pcitest3.la.locus.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.22 (Windows; I; 16bit)
-
- scottr@belle.bork.com (Randy Scott) wrote:
- >Gene Wirchenko (genew@mindlink.bc.ca) wrote:
- >: >Try this:
- >: > if(something_happened) do_something_else();
- >:
- >: Not as clear as it should be by my standards. YMMV.
- >
- >NOT CLEAR? Hello? That piece of code is just about as clear as it
- >gets!
- >
- >: >or this:
- >: > if(something_happened)
- >: > { do_something_else(); }
- >:
- >: Extraneous braces cause pause.
- >
- >I would have to agree, use braces only when absolutely necessary.
- >
- >
- >Randy Scott
-
-
- Although this is somewhat of a religious argument, we teach our students
- to always put in the braces even when there is only a single statement, .e.g,
-
- if (expression)
- {
- statement;
- }
-
-
- This code is easier to maintain, always consistent, and (for most who've
- really studied the problem) easier to read.
-
- Personally, I get rather upset when people "hide" braces at the end of
- other statements, e.g.,
-
- if (expression) {
- statement;
- }
-
- or
-
- if (expression)
- { statement; }
-
- But that's my opinion. I personally believe the first version above is better
- because it's easy to see where the block begins and ends, the statement to
- which it is attached, and the braces also add some needed whitespace to the
- program making it easier to read. But once again, that's just my opinion,
- I'm not going to try to talk someone who has been doing some other way for
- 20 years out of their favorite indenting scheme.
-
-
-